package com.struggle.rabbitmqconsumer.listener.topic;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.struggle.common.QueueConstants;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @className TopicAllReceiver
 * @Description TODO
 * @Author liuwj3
 * @Date 2019/10/12 0012 下午 4:00
 **/

@Component
public class TopicAllReceiver {

    @RabbitListener(queues = QueueConstants.TOPIC_QUEUE_SECOND)
    @RabbitHandler
    public void process(Map<String, Object> message) throws Exception {
        System.out.println(QueueConstants.TOPIC_QUEUE_SECOND + "收到消息：" + new ObjectMapper().writeValueAsString(message));
    }

    @RabbitListener(queues = QueueConstants.TOPIC_QUEUE_FIRST)
    @RabbitHandler
    public void process2(Map<String, Object> message) throws Exception {
        System.out.println(QueueConstants.TOPIC_QUEUE_FIRST + "收到消息：" + new ObjectMapper().writeValueAsString(message));
    }
}
